package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 通勤方式
 * @author hans.zhang
 */
@Getter
@AllArgsConstructor
public enum CommutingMode {
    WALKING("步行","walking", 4000),
    RIDING("自行车","riding", 12000),
    DRIVING("汽车","driving", 30000),
    TRANSIT("公交","transit", 20000);

    private String name;
    private String value;
    // 时速配置， 每小时行驶多少米
    private Integer Speed;

    public static Integer getSpeedByValue(String value) {
        CommutingMode commutingMode = Arrays.stream(CommutingMode.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(commutingMode != null,"CommutingMode:{}不存在",value);
        return commutingMode.getSpeed();
    }
}
